﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using prototype123.data_access;
using prototype123.controllers;
using prototype123.models;

namespace prototype123
{
    public partial class login_form : Form
    {
        public login_form()
        {
            InitializeComponent();
        }

        // If the user clicks the btnLogin, then the System checks if the Username
        // exists, and then checks if the password is correct.
        private void btnLogin_Click(object sender, EventArgs e)
        {
            
            // Ensure that txtPassword and txtUsername are not empty. If they are empty, then do nothing

            // -----------------------------------------------------------------
            // The code in this if statement is only for testing purposes, and is temporary!!!
            if (txtPassword.Text == "" && txtUsername.Text == "") {
                this.Visible = false;
                prototype123.Program.m_frm.Visible = true;
                return;
            }
            //----------------------------------------------------------------------
           

            //alert: testing code ahead
            UserDAO login = new UserDAO();
            login.Connect();


            User tester = login.Load("dwoost", "worthwhile");
            User test2 = login.Load("sschaub", "failurepass");
            User test3 = login.Load("imnotinhere", "hwhocares");

            login.Disconnect();
            

            // Create object to check if the username exists 

            // LoginController lg_ctrl = new LoginController(txtUsername, txtPassword);

            // bool login_success = lg_ctrl.login();

            // If login_success is true, then exit this screen, and open the main_screen.

            // if login_succes is fale, then give error message
        }

        // When the user clicks the cancel button, the program closes
        private void btnCancel_Click(object sender, EventArgs e)
        {
            // close the program
            this.Close();
        }


    }
}
